# SA2410.ZCE

from pandas import DataFrame

from app_config import get_pro, get_engine_ts

pro = get_pro()
engine = get_engine_ts()

if __name__ == '__main__':
    import pandas as pd

    sql_daily = f"""
        select * from daily_future order by id
        """
    df = pd.read_sql_query(sql_daily, engine)
    # 按 col1 分组
    grouped = df.groupby('group')
    df_concat = pd.DataFrame({})
    # 遍历每个分组并打印
    for group_name, group_df in grouped:
        group_df['pct_change'] = group_df['price'].pct_change()
        df_concat = pd.concat([df_concat, group_df], ignore_index=True)

    print(df_concat)
    df_concat['abs_change'] = df_concat['pct_change'].abs()
    values = df_concat.sort_values(by='abs_change', ascending=False)
    print(values.head(20))
